resource "google_monitoring_metric_descriptor" "<%= ctx[:primary_resource_id] %>" {
  description = "Daily sales records from all branch stores."
  display_name = "<%= ctx[:vars]["display_name"] %>"
  type = "custom.googleapis.com/stores/<%= ctx[:vars]["type"] %>"
  metric_kind = "GAUGE"
  value_type = "DOUBLE"
  unit = "{USD}"
}

resource "google_monitoring_alert_policy" "alert_policy" {
  display_name = "<%= ctx[:vars]["display_name"] %>"
  combiner     = "OR"
  conditions {
    display_name = "test condition"
    condition_threshold {
      filter     = "metric.type=\"${google_monitoring_metric_descriptor.<%= ctx[:primary_resource_id] %>.type}\" AND resource.type=\"gce_instance\""
      duration   = "60s"
      comparison = "COMPARISON_GT"
    }
  }
}
